<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //Number.prototype.toString 的第一个参数支持传一个进制数。右移 >>> 0 可以解决负数补码展示的问题
    var toHex = function (num) {
      return (num >>> 0).toString(16)
    };
    console.log(toHex(-1));
  </script>
</body>

</html>